package org.hzy.dao.impl;

import java.util.List;

import javax.swing.tree.ExpandVetoException;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hzy.dao.ITUserDao;
import org.hzy.entity.TUser;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class TUserDaoImpl extends BaseDao<TUser> implements ITUserDao{

	public TUser get(Integer id) {
		// TODO Auto-generated method stub
		return super.get_object(id);
	}
	
	public static void main(String[] args) throws Exception {
		ApplicationContext ctx=new ClassPathXmlApplicationContext("beans1.xml");
		ITUserDao tu=ctx.getBean("Td",ITUserDao.class);
		
		System.out.println(tu.get("张三").getUname());
		
//		tu.save(new TUser(5,"aabv","135"));	
	}

	public boolean save(TUser tu){
		// TODO Auto-generated method stub
		super.create(tu);
		return true;
	}

	public TUser get(String uname) {
		// TODO Auto-generated method stub
		Query query=super.getSession().createSQLQuery("select * from t_user t where t.uname=?").addEntity(TUser.class);
		query.setString(0, uname);
		return (TUser) query.uniqueResult();
	}
}
